package com.example.work_study_system.web.controller;


import com.example.work_study_system.model.domain.Teacher;
import com.example.work_study_system.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/teacher")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;

    @GetMapping("/list")
    public List<Teacher> list() {
        return teacherService.list();
    }

    @GetMapping("/{id}")
    public Teacher getById(@PathVariable Integer id) {
        return teacherService.getById(id);
    }

    @PostMapping("/add")
    public boolean add(@RequestBody Teacher teacher) {
        return teacherService.save(teacher);
    }

    @PutMapping("/update")
    public boolean update(@RequestBody Teacher teacher) {
        return teacherService.updateById(teacher);
    }

    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable Integer id) {
        return teacherService.removeById(id);
    }
} 